//将时间戳转换为日期时间格式
function timestampToTime (timestamp) {
    var date = new Date(timestamp * 1000);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
    Y = date.getFullYear() + '-';
    M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
    D = date.getDate() + ' ';
    h = date.getHours() + ':';
    m = date.getMinutes() + ':';
    s = date.getSeconds();
    return Y+M+D+h+m+s;
};

var Utils = {};

Utils.layer = {
    'alert':function(msg,options,callback){
        var base_options = {'shade':[0.5,'#FFFFFF']};
        if(typeof options == 'function'){
            callback = options;
            options = base_options;
        }
        options = Object.assign(options,base_options);
        return layui.layer.alert(msg,options,callback);
    },
    'open':function(options){
        options.shade = [0.5,'#FFFFFF'];
        return layui.layer.open(options);
    },
    'msg':function(content,options,callback){
        var base_options = {'shade':[0.5,'#FFFFFF'],time: 2000};
        if(typeof options == 'function'){
            callback = options;
            options = base_options;
        }
        if(!options){
            options = {};
        }
        options = Object.assign(base_options,options);
        return layui.layer.msg(content,options,callback);
    },
    'confirm':function(content,options,yes,cancel){
        var base_options = {'shade':[0.5,'#FFFFFF']};
        if(typeof options == 'function'){
            yes = options;
            options = base_options;
        }
        if(!options){
            options = {};
        }
        options = Object.assign(base_options,options);
        return layui.layer.confirm(content,options,yes,cancel);
    },
    'close':function (index) {
        return layui.layer.close(index)
    },
    'closeAll':function () {
        return layui.layer.closeAll();
    },
    'load':function (icon,options) {
        return layui.layer.load(icon,options)
    }
};


function getStatus(e){
    if(e=='0'){
        return "待支付"
    }else if(e=='1'){
        return "待发货"
    }else if(e=='3'){
        return "待收货"
    }else if(e=='4'){
        return "退货中"
    }else if(e=='5'){
        return "已完成"
    }else if(e=='6'){
        return "关闭"
    }else if(e=='7'){
        return "拼团中"
    }
}
function TestFileSuffix(name) {
    var ts = /\.[^\.]+$/.exec(name);
    mimetypes = ['.png', '.jpg', '.jpeg'];
    return mimetypes.indexOf(ts[0]);
}